<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>个人资料</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${ctx}/resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${ctx}/resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
	<form class="layui-form layui-row" lay-filter="dataFrm" id="dataFrm">
		<div class="layui-col-md3 layui-col-xs12 user_right">
			<div class="layui-upload-list">
				<img class="layui-upload-img layui-circle userFaceBtn userAvatar" id="userFace">
				<input type="hidden" name="carimg" id="carimg">
			</div>
			<button type="button" class="layui-btn layui-btn-primary userFaceBtn" id="uploadUserFace"><i class="layui-icon">&#xe67c;</i>掐指一算，我要换一个头像了</button>
		</div>
	
		<div class="layui-col-md6 layui-col-xs12">
			<div class="layui-form-item">
				<label class="layui-form-label">用户名</label>
				<div class="layui-input-block">
					<input type="hidden" name="userid">
					<input type="text" name="loginname" value="" disabled class="layui-input layui-disabled">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">真实姓名</label>
				<div class="layui-input-block">
					<input type="text" name="realname" value="" placeholder="请输入真实姓名" class="layui-input realName">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">身份证号码</label>
				<div class="layui-input-block">
					<input type="text" name="identity" value="" placeholder="请输入身份证号码" class="layui-input realName">
				</div>
			</div>
			<div class="layui-form-item" pane="">
				<label class="layui-form-label">性别</label>
				<div class="layui-input-block userSex">
					<input type="radio" name="sex" value="1" title="男" checked="">
					<input type="radio" name="sex" value="0" title="女">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">手机号码</label>
				<div class="layui-input-block">
					<input type="tel" name="phone" value="" placeholder="请输入手机号码" class="layui-input userPhone">
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">用户地址</label>
				<div class="layui-input-block">
					<input type="text" name="address" value="" placeholder="请输入用户地址"  class="layui-input userPhone">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">用户职位</label>
				<div class="layui-input-block">
					<input type="text" name="position" value="" placeholder="请输入用户职位" class="layui-input userPhone">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="button" class="layui-btn" id="doSubmit">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</div>
	</form>
	
	<script src="${ctx }/resources/layui/layui.js"></script>
	<script type="text/javascript">
	layui.use([ 'element', 'jquery', 'layer', 'form', 'upload' ], function() {
		var $ = layui.jquery;
		var element = layui.element;
		var layer = layui.layer;
		var form = layui.form;
		var upload = layui.upload;
		
		$.post("${ctx}/login/getLoginUser.action",function(res){
			form.val("dataFrm",res);
			$('#userFace').attr('src',"${ctx}/user/downloadFaceFile.action?path="+res.carimg);
		})
		
		$("#doSubmit").click(function(){
			var params = $("#dataFrm").serialize();
			$.post("${ctx}/login/updateUser.action",params,function(res){
				layer.msg(res.msg);
			})
		})
		
		
		//上传缩略图
	    upload.render({
	        elem: '#uploadUserFace',
	        url: '${ctx}/user/uploadFile.action',
	        acceptMime: 'image/*',
	        field: 'mf',
	        done: function(res, index, upload){
	        	$('#userFace').attr('src',"${ctx}/user/downloadFaceFile.action?path="+res.data.src);
	            $('#carimg').val(res.data.src);
	            $('#carimgDiv').css("background","#fff");
	        }
	    });
	})
	</script>
</body>
</html>